import 'package:lishopflu/base/base_page.dart';
import 'package:lishopflu/base/view_import.dart';
import 'package:lishopflu/bean/id_text_bean.dart';
import 'package:photo_view/photo_view.dart';
import 'package:photo_view/photo_view_gallery.dart';

import 'photo_ctl.dart';

class PhotoPage extends BasePage<PhotoCtl>{

  @override
  void onCreate(BuildContext mContext) {

  }

  @override
  Widget pageBody(BuildContext context) {
    return GestureDetector(
      onTap: (){
        finish();
      },
      child: Container(
          color: Colors.black,
          child: PhotoViewGallery.builder(
            scrollPhysics: const BouncingScrollPhysics(),
            builder: (BuildContext context, int index) {
              IdTextBean item = controller.galleryItems[index];
              return PhotoViewGalleryPageOptions(
                imageProvider: AssetImage(item.str),
                initialScale: PhotoViewComputedScale.contained * 0.8,
                heroAttributes: PhotoViewHeroAttributes(tag: item.id),
                maxScale: 3.0,
                minScale: 0.1,
              );
            },
            itemCount: controller.galleryItems.length,
            loadingBuilder: (context, event) => Center(
              child: Container(
                width: 20.0,
                height: 20.0,
                child: CircularProgressIndicator(
                  value: event == null ? 0 : event.cumulativeBytesLoaded / event.expectedTotalBytes,
                ),
              ),
            ),
            backgroundDecoration: BoxDecoration(),
            pageController: controller.pageController,
            onPageChanged: (index){

            },
          )
      ),
    );
  }

  @override
  Widget appbar() {
    return null;
  }
}